package net.teamclerks.rpgf.script;

import java.util.List;

import net.teamclerks.rpgf.script.action.Action;
import net.teamclerks.rpgf.script.director.Director;

/**
 * Script is the list of all Actions which can be fired in the context of
 * the current Scene. When a Scene is loaded, all the Actions pertaining to
 * the Scene also load and are stored in the Script. 
 * @author msmith
 */
public class Script
{
  /// CONTROL DATA ///
  protected Director director;
  /**
   * List of Actions.
   */
  protected List<Action> actions;
  
  /// DENY CONSTRUCTOR ///
  private Script(){}
  
  /// PUBLIC CONSTRUCTOR ///
  public Script(Director director)
  {
    this();
    this.director = director;
  }
  
  /// PUBLIC METHODS ///
  /**
   * List of Actions pertaining to a specific Scene. This list includes
   * all Actions for the scene - DialogActions, ChestActions, etc. When
   * an Action calls act(), it can tell other Actions to act as well (or
   * destruct, etc) in the scene.
   */
  public final List<Action> getActions()
  {
    return this.actions;
  }
  /**
   * Sets the list of Actions for this script.
   * @param actions
   */
  public final void setActions(List<Action> actions)
  {
    this.actions = actions;
  }
  /**
   * Adds a single Action to the queue.
   * @param action
   */
  public final void addAction(Action action)
  {
    if(actions != null) actions.add(action);
  }
  /**
   * Removes a single Action from the queue (in any place,
   * queue adjusts size automatically to compensate for gaps).
   * @param action
   */
  public final void removeAction(Action action)
  {
    if(actions != null)
    {
      actions.remove(action);
      action = null;
    }
  }
}
